package com.example.demo.service.impl;

import com.example.demo.api.dto.DepartmentDTO;
import com.example.demo.domain.entity.Department;
import com.example.demo.domain.repository.DepartmentRepository;
import com.example.demo.service.DepartmentService;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class DepartmentServiceImpl implements DepartmentService {
    private final DepartmentRepository departmentRepository;

    public DepartmentServiceImpl(DepartmentRepository departmentRepository) {
        this.departmentRepository = departmentRepository;
    }

    @Override
    public List<Department> findDepartmentList() {
        return departmentRepository.listDepartment();
    }

    @Override
    public Department findDepartmentById(Long departmentId) {
        return departmentRepository.getDepartment(departmentId);
    }

    @Override
    public Integer countDepartmentLen() {
        return departmentRepository.countDepartmentLen();
    }

    @Override
    public Integer insertDepartment(DepartmentDTO departmentDTO) {
        return departmentRepository.insertDepartment(departmentDTO);
    }

    @Override
    public Integer removeDepartment(Long departmentId) {
        return departmentRepository.removeDepartment(departmentId);
    }

    @Override
    public Integer updateDepartment(DepartmentDTO departmentDTO) {
        return departmentRepository.updateDepartment(departmentDTO);
    }

    @Override
    public List<Department> findDepartmentListByIdList(List<Long> departmentIds) {
        return departmentRepository.listDepartmentByIdList(departmentIds);
    }

    @Override
    public void insertByList(List<DepartmentDTO> departments) {
        departmentRepository.insertByList(departments);
    }
}
